package com.cyl.manager.lbs.service;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cyl.manager.lbs.domain.LbsZbjl;
import com.cyl.manager.lbs.mapper.LbsZbjlMapper;
import com.cyl.manager.oms.domain.query.DpOrderQuery;
import com.cyl.manager.oms.domain.vo.DpOrderProductVO;
import com.cyl.manager.oms.domain.vo.DpOrderVO;
import com.cyl.manager.oms.mapper.OrderMapper;
import com.cyl.manager.pms.domain.query.ProductQuery;
import com.ruoyi.livesass.api.sync.LiveTrafficDataSynService;

import cn.hutool.core.date.DateUtil;


/**
 * 直播列表大屏业务层处理
 *
 *
 * @author zcc
 */
@Service
public class LbsZbDpService {
	
	private static final Logger LOG = LoggerFactory.getLogger(LiveTrafficDataSynService.class);
	
  
    @Autowired
    private OrderMapper orderMapper;
     
    @Autowired
    private LbsZbjlMapper lbsZbjlMapper;
    
    public List<DpOrderProductVO> selectDpCjph(DpOrderQuery dpOrderQuery){
    	return orderMapper.selectDpCjph(getDpOrderQueryMr(dpOrderQuery));
    }
    
    public List<DpOrderVO> selectDpCjzs(DpOrderQuery dpOrderQuery){
    	return orderMapper.selectDpCjzs(getDpOrderQueryMr(dpOrderQuery));
    }
    
    
    public List<DpOrderVO> selectDpGmvCjzs(DpOrderQuery dpOrderQuery){
    	return orderMapper.selectDpGmvCjzs(getDpOrderQueryMr(dpOrderQuery));
    }
    
    
    
    public List<DpOrderVO> selectDp5min(DpOrderQuery dpOrderQuery){
    	return orderMapper.selectDp5min(getDpOrderQueryMr(dpOrderQuery));
    }
    
    
    public List<DpOrderVO> selectDpTjByProductId(DpOrderQuery dpOrderQuery){
    	return orderMapper.selectDpTjByProductId(getDpOrderQueryMr(dpOrderQuery));
    }
    
    
	public Integer selectProductWzfTj(DpOrderQuery dpOrderQuery) {
    	return orderMapper.selectProductWzfTj(getDpOrderQueryMr(dpOrderQuery));
	}
    
	public Integer selectProductXl(Long productId) {
    	return orderMapper.selectProductXl(productId);
	}
	
	public DpOrderVO selectProductXlTj(Long productId) {
    	return orderMapper.selectProductXlTj(productId);
	}
	
	

	
	private DpOrderQuery getDpOrderQueryMr(DpOrderQuery dpOrderQuery) {
		if(dpOrderQuery.getStrTime() == null || dpOrderQuery.getEndTime() == null ) {
			LbsZbjl lbsZbjl = lbsZbjlMapper.selectById(dpOrderQuery.getLbsZbjlId());
			dpOrderQuery.setStrTime(DateUtil.parseLocalDateTime(lbsZbjl.getJhkssj()));
			dpOrderQuery.setEndTime(DateUtil.parseLocalDateTime(lbsZbjl.getJhjssj()));
		}
		return dpOrderQuery;
	}
 
}
